﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Srvtools;

public partial class ServicesSheet_OfficeSupplies : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            InitializeComponent();
            Master.DataSource = WMaster;
            Detail.DataSource = WMaster;

            if (this.Page.Request.QueryString["NAVMODE"] == "0") //"0"就是Normal
            {
                wgvDetail.CreateInnerNavigator = false; //去除新增Icon
                wgvDetail.Columns[0].Visible = false; //去除編輯刪除Icon
            }
            string start = ConfigurationManager.AppSettings["StartOffice"];
            string end = ConfigurationManager.AppSettings["EndOffice"];
            if (start != null && end != null)
            {
                int startOffice = int.Parse(start);
                int endOffice = int.Parse(end);
                if (DateTime.Now.Day < startOffice || DateTime.Now.Day > endOffice)
                {
                    this.FLWebNavigator1.NavControls.RemoveAt("Add");
                    this.FLWebNavigator1.NavControls.RemoveAt("Submit");
                    this.FLWebNavigator1.NavControls.RemoveAt("Pause");
                    this.FLWebNavigator1.NavControls.RemoveAt("Notify");
                    //this.FLWebNavigator1.Visible = false;
                    //this.wfvMaster.Visible = false;
                    //this.wgvDetail.Visible = false;
                    //this.WebStatusStrip1.Visible = false;
                    this.Label2.Text = "！办公用品的申请请在每个月的10号到15号之间申请，如果要继续申领，请到前台做临时领用。";
                }
                else
                {
                    this.Label2.Visible = false;
                }
            }


            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "~/Help/ServicesSheet/办公品申请.htm";
            master.PageName = "办公用品申请";
            master.PicUrl = "";
            master.IntiBar();
        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServicesSheet_OfficeSupplies));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = true;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "ServiceSheet.Services_OfficeSupplies";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }

    protected void WebNavigator1_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "cmdFirst" || e.CommandName == "cmdPrevious"
            || e.CommandName == "cmdNext" || e.CommandName == "cmdLast")
        {
            Detail.ExecuteSelect(wfvMaster);
            DataBind();
        }
        else if (e.CommandName == "cmdAdd")
        {
            Detail.ExecuteAdd(wfvMaster);
            DataBind();
        }
        else if (e.CommandName == "cmdDelete")
        {
            Detail.ExecuteSelect(wfvMaster);
            DataBind();
        }
        else if (e.CommandName == "cmdApply" && wfvMaster.AllValidateSucess)
        {
            Detail.ExecuteSelect(wfvMaster);
            DataBind();
        }

    }

    protected void wfvMaster_PageIndexChanged(object sender, EventArgs e)
    {
        Detail.ExecuteSelect(wfvMaster);
        DataBind();
    }

    protected void wfvMaster_AfterInsertLocate(object sender, EventArgs e)
    {
        Detail.ExecuteSelect(wfvMaster);
        DataBind();
    }

    protected void wfvMaster_Canceled(object sender, EventArgs e)
    {
        Detail.ExecuteSelect(wfvMaster);
        DataBind();
    }

    protected string GetEmpId()
    {
        String str = Srvtools.CliUtils.GetValue("_UserCode")[1].ToString();
        str = int.Parse(str).ToString();
        return str;
    }

    
}
